/*
 * @Descripttion: 
 * @Author: lx
 * @Date: 2022-04-12 08:38:55
 * @LastEditTime: 2022-05-19 22:33:15
 */
// 从electron包中导入app,BrowserWindow模块
const {app, BrowserWindow} = require('electron')
const path = require('path')

function createWindow() {
    const win = new BrowserWindow({
        width: 800,
        height: 600,
        webPreferences: {
            preload: path.join(__dirname, 'preload.js')
        }
    })
    win.loadFile('./dist/index.html')
    // 打开控制台
    // win.webContents.openDevTools()
}

app.whenReady().then(() => {
    createWindow()
    app.on('activate', () => {
        if (BrowserWindow.getAllWindows().length === 0) {
            createWindow()
        }
    })
})
// 添加了一个新的侦听器，当应用程序不再有任何打开窗口时试图退出
app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit()
    }
})
